<template>
	<view class="contain cu-card">
		<view class="cu-item shadow " style="">
			<view class="cu-list text-content " v-for="(item, index) in modeData" :key="index">
				<view class="flex flex-direction justify-between padding " style="border-bottom: 1px solid #DADADA;">
					<view class="">
						<text class="text-gray">车次：</text>
						<text>{{ item.TruckTransportNO }}</text>
					</view>
					<view class="" style="flex: 1;">
						<text class="text-gray">签到时间：</text>
						<text class="padding">{{ item.CZSignDate }}</text>
						<text>{{ item.status }}</text>
					</view>
				</view>
			</view>
		</view>
		<view class="signIn" :style="{ 'background-color': isSign ? '#9FACA3' : '#27B148' }" :disabled="isSign" @click="sign"><text>扫描签到</text></view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			openid: '',
			modeData: [
				// {velchee:'0001',time:'09:35',status:'已签到'},
				// {velchee:'0003',time:'08:35',status:'未签到'},
				// {velchee:'0004',time:'07:35',status:'已签到'},
			],
			isSign: false,
			pageType:''
		};
	},
	onLoad(e){
		console.log('eeee',e)
		this.pageType=e.page
	},
	mounted() {
		const session = uni.getStorageSync('session');
		this.openid = session.openid;
		console.log('id',session)
		this.getDetail(session.openid);
	},
	methods: {
		getDetail(id) {
			this.$store.dispatch('uni/GetCZSignInfoList', { openid: id }).then(res => {
				console.log('ressss', res);
				this.modeData = res.Data.CZSignList;
				this.isSign = !res.Data.IsEnableCZSign;
			});
		},
		sign() {
			if(this.isSign) return
			uni.scanCode({
				success: res => {
					if (res) {
						this.$store
							.dispatch('uni/AddCZSign', {
								openid: this.openid,
								QRContent: res
							})
							.then(v => {
								if(v.Code===0){
									this.isSign=!v.Data.IsEnableCZSign
									uni.showToast({
										title: v.Message,
										duration: 1500
									});
									setTimeout(() => {
										this.isSign = true;
										this.getDetail(this.openid)
										if(this.pageType){
											uni.switchTab({
												url:'/pages/lineUp/lineUpList'
											})
										}
									}, 1500);
								}
							});
					}
				}
			});
		}
	}
};
</script>

<style scoped lang="scss">
.contain {
	position: relative;
	height: 100vh;
	width: 100vw;
}
.signIn {
	position: absolute;
	left: 50%;
	top: 50%;
	transform: translate(-50%, -50%);
	z-index: 10;
	width: 120px;
	height: 120px;
	border-radius: 50%;
	background-color: #27b148;
	color: #ffffff;
	font-size: 16px;
	text-align: center;
	box-shadow: 0 3px 2px #90a19a;

	text {
		line-height: 120px;
		font-weight: bold;
	}
}
</style>
